package com.xpgk.common.handlers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jfinal.handler.Handler;
import com.jfinal.log.Log;
import com.xpgk.common.tools.ToolWeb;

/**
 * 全局Handler，设置一些通用功能 描述：主要是一些全局变量的设置，再就是日志记录开始和结束操作
 */
public class GlobalHandler extends Handler {

	private static final Log log = Log.getLog(GlobalHandler.class);

	@Override
	public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {

		log.debug("设置 web 路径");
		String cxt = ToolWeb.getContextPath(request);
//		String ws = "ws" + cxt.substring(cxt.indexOf(":"), cxt.length()) + "/websocket";
		request.setAttribute("cxt", cxt);
//		request.setAttribute("ws", ws);

		// server

		next.handle(target, request, response, isHandled);

	}
}
